package com.tvunetworks.center.user.service;

import com.github.pagehelper.PageInfo;
import com.tvunetworks.center.common.model.LoginUser;
import com.tvunetworks.center.user.model.UpdateInstanceParam;
import com.tvunetworks.center.user.model.UserInstance;
import com.tvunetworks.center.user.model.param.InstanceParam;
import com.tvunetworks.center.user.model.param.PageUserInstanceParam;
import com.tvunetworks.center.user.model.param.api.PageRunningInstanceIdsParam;
import com.tvunetworks.center.user.model.vo.InstanceMessageVo;
import com.tvunetworks.center.user.model.vo.UserInstanceVo;
import com.tvunetworks.center.user.model.vo.api.PageRunningInstanceIdsVo;

import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
 * @author Etan Yang
 * @data: 2021/6/4 19:05
 * @program: tvucc-aggregator
 * @description:
 */
public interface UserInstanceService {
    /**
     *
     * @param loginUser loginUser
     * @param imageType imageType
     * @return List
     * @throws IOException IOException
     */
    List listActiveRegion(LoginUser loginUser, String imageType) throws IOException;

    /**
     *
     * @param session session
     * @param loginUser loginUser
     * @param instanceParam instanceParam
     * @return UserInstance
     * @throws IOException IOException
     */
    UserInstance createInstance(String session, LoginUser loginUser, InstanceParam instanceParam) throws IOException;

    /**
     *
     * @param loginUser loginUser
     * @param instanceParam instanceParam
     * @throws IOException IOException
     */
    void shutdownInstance(LoginUser loginUser, InstanceParam instanceParam) throws IOException;

    /**
     *
     * @param param param
     */
    void updateInstance(UpdateInstanceParam param);

    /**
     *
     * @param id id
     * @return UserInstance
     */
    UserInstance getById(String id);

    /**
     *
     * @param instanceId instanceId
     * @return UserInstance
     */
    UserInstance getByInstanceId(String instanceId);

    /**
     *
     * @param param param
     * @return PageInfo
     */
    PageInfo<UserInstanceVo> pageUserInstance(PageUserInstanceParam param);

    /**
     *  remedyUserInstancePeerId
     */
    // 开关机流程失败导致 TPC 设备需要绑定和释放的补救任务
    void remedyUserInstancePeerId();

    /**
     *
     * @throws IOException IOException
     */
    // 定时查询实例如果被关闭了，修改 UserInstance 为关闭状态
    void syncInstanceStatus() throws IOException;

    /**
     * sendRunningInstanceEmailToSupport
     */
    void sendRunningInstanceEmailToSupport();

    /**
     *
     * @return Map
     * @throws IOException IOException
     */
    Map<String, String> multiRNum() throws IOException;

    /**
     *
     * @return Map
     * @throws IOException IOException
     */
    Map<String, String> multiImageType() throws IOException;

    /**
     *  shutdownSchedule
     */
    void shutdownSchedule();

    /**
     * 根据projectType获取正在执行的instanceId
     * @param param 参数
     * @return 返回正在running的instanceId
     */
    PageRunningInstanceIdsVo<String> pageRunningInstanceIds(PageRunningInstanceIdsParam param);

    /**
     * 获取查询instanceId对应的信息
     * @param instanceIds instanceIds
     * @return 返回查询instanceId对应的信息
     */
    List<InstanceMessageVo> getInstanceMessage(List<String> instanceIds);
}
